﻿using System.Xml.Serialization;

namespace PrearrangedChaos.AgileZen.Service.Model
{
    public class ProjectUpdater : ModelBase, IProjectUpdater
    {
        protected IUser _owner;
        private string _description;
        private string _details;
        private string _name;

        /// <remarks/>
        [XmlElement(ElementName = "description")]
        public string DescriptionXmlElement
        {
            get { return _description; }
            set
            {
                if (!string.IsNullOrEmpty(value))
                    _description = value;
                else
                    _description = null;

                this.Unmodified("description");
            }
        }

        [XmlIgnore]
        public string Description
        {
            get { return _description; }
            set
            {
                if (_description == value)
                    return;

                _description = value;
                this.Modified("description");
            }
        }

        public bool DescriptionXmlElementSpecified { get { return this.IsModified("description"); } }

        /// <remarks/>
        [XmlElement(ElementName = "details")]
        public string DetailsXmlElement
        {
            get { return _details; }
            set
            {
                if (!string.IsNullOrEmpty(value))
                    _details = value;
                else
                    _details = null;

                this.Unmodified("details");
            }
        }

        [XmlIgnore]
        public string Details
        {
            get { return _details; }
            set
            {
                if (_details == value)
                    return;

                _details = value;
                this.Modified("details");
            }
        }

        public bool DetailsXmlElementSpecified { get { return this.IsModified("details"); } }

        /// <remarks/>
        [XmlElement(ElementName = "name")]
        public string NameXmlElement
        {
            get { return _name; }
            set
            {
                if (!string.IsNullOrEmpty(value))
                    _name = value;
                else
                    _name = null;

                this.Unmodified("name");
            }
        }

        [XmlIgnore]
        public string Name
        {
            get { return _name; }
            set
            {
                if (_name == value)
                    return;

                _name = value;
                this.Modified("name");
            }
        }

        public bool NameXmlElementSpecified { get { return this.IsModified("name"); } }

        [XmlIgnore]
        public IUser Owner
        {
            get { return _owner; }
            set
            {
                if (_owner == value)
                    return;

                _owner = value;
                this.Modified("owner");
            }
        }

        [XmlElement(ElementName = "owner")]
        public User OwnerXmlElement
        {
            get { return _owner as User; }
            set
            {
                _owner = value;
                this.Unmodified("owner");
            }
        }

        public bool OwnerXmlElementSpecified { get { return this.IsModified("owner"); } }

    }
}